
<!DOCTYPE html>
<html>
<head>
  <title>Faye Test</title>
  <script type="text/javascript" src="/faye/faye-browser-min.js"></script>
</head>
<body role='document' data-offset='50'>
 <div class='container' role='main'>
    <div id='main' class='container-fluid'></div>
  </div>
<script type="text/javascript">
    var client = new Faye.Client('/faye', {
      timeout: 120
    });
    
    Faye.logger = window.console;

    client.on('transport:down', function() {
      console.log('离线');
    });

    client.on('transport:up', function() {
      console.log('在线');
    });

    var subscription = client.subscribe('/notifications/test', function(message) {
      console.log(message);
    });

    subscription.then(function() {
      console.log('订阅成功');
    });

    var publication = client.publish('/notifications/test', { text: '你好！' });

    publication.then(function() {
      console.log('发送成功');
    }, function(error) {
      console.log('发送失败：' + error.message);
    });

    </script>
</body>
</html>